﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CTPAdapter;
using System.Threading;

namespace CTPDemo.Trader
{
    class TraderSpi:TraderApiInter,CSTraderSpiInter
    {
        /// <summary>
        /// 前置编号
        /// </summary>
        int FRONT_ID = 0;
        /// <summary>
        /// 会话编号
        /// </summary>
        int SESSION_ID = 0;
        /// <summary>
        /// 报单引用
        /// </summary>
        string ORDER_REF = "";

        /// <summary>
        /// 经纪公司代码
        /// </summary>
        string _BrokerID;

        /// <summary>
        /// 投资者代码
        /// </summary>
        string _InvestorID;

        /// <summary>
        /// 用户密码
        /// </summary>
        string _Password;        
                
        /// <summary>
        /// 交易API接口
        /// </summary>
        CSTraderApi _traderApi;


        public TraderSpi(string investorID, string password,CSTraderApi traderApi)
        {
            _BrokerID = "2030";
            _InvestorID = investorID;
            _Password = password;
            _traderApi = traderApi;
    
        }

        public bool IsErrorRspInfo(CSCThostFtdcRspInfoField pRspInfo)
        {
            // 如果ErrorID != 0, 说明收到了错误的响应
            bool bResult = ((pRspInfo != null) && (pRspInfo.ErrorID != 0));
            if (bResult)
            //cerr << "--->>> ErrorID=" << pRspInfo->ErrorID << ", ErrorMsg=" << pRspInfo->ErrorMsg << endl;
            {
                TraderTest.TraderTest1.DisplayError("ErrorID=" + pRspInfo.ErrorID + "    ErrorMsg=" + pRspInfo.ErrorMsg);
            }
            return bResult;
        }

        public bool IsMyOrder(CSCThostFtdcOrderField pOrder)
        {
	        return ((pOrder.FrontID == FRONT_ID) &&
			        (pOrder.SessionID == SESSION_ID) &&
			        (pOrder.OrderRef == ORDER_REF));
        }

        public bool IsTradingOrder(CSCThostFtdcOrderField pOrder)
        {
            return ((pOrder.OrderStatus != (sbyte)CSTThostFtdcOrderStatusType.CSTHOST_FTDC_OST_PartTradedNotQueueing) &&
                    (pOrder.OrderStatus != (sbyte)CSTThostFtdcOrderStatusType.CSTHOST_FTDC_OST_Canceled) &&
                    (pOrder.OrderStatus != (sbyte)CSTThostFtdcOrderStatusType.CSTHOST_FTDC_OST_AllTraded));
        }

        /// <summary>
        /// 用户登录请求
        /// <summary>
        public void ReqUserLogin()
        {
            CSCThostFtdcReqUserLoginField req = new CSCThostFtdcReqUserLoginField(); ;
            req.BrokerID = _BrokerID;
            req.UserID = _InvestorID;
            req.Password = _Password;

            _traderApi.ReqUserLogin(req);
        }

        /// <summary>
        /// 投资者结算结果确认
        /// <summary>
        public void ReqSettlementInfoConfirm()
        {
            CSCThostFtdcSettlementInfoConfirmField req = new CSCThostFtdcSettlementInfoConfirmField();
            //memset(&req, 0, sizeof(req));
            req.BrokerID = _BrokerID;
            req.InvestorID = _InvestorID;
            //strcpy(req.BrokerID, BROKER_ID);
            //strcpy(req.InvestorID, INVESTOR_ID);
            int iResult = _traderApi.ReqSettlementInfoConfirm(req);
            //cerr << "--->>> 投资者结算结果确认: " << ((iResult == 0) ? "成功" : "失败") << endl;
        }

        /// <summary>
        /// 请求查询合约
        /// <summary>
        public void ReqQryInstrument()
        {
            CSCThostFtdcQryInstrumentField req = new CSCThostFtdcQryInstrumentField();
            //memset(&req, 0, sizeof(req));
            req.InstrumentID = "IF1205";
            int iResult = _traderApi.ReqQryInstrument(req);
            //cerr << "--->>> 请求查询合约: " << ((iResult == 0) ? "成功" : "失败") << endl;
        }

        /// <summary>
        /// 请求查询资金账户
        /// <summary>
        public void ReqQryTradingAccount()
        {
            CSCThostFtdcQryTradingAccountField req = new CSCThostFtdcQryTradingAccountField();
            //memset(&req, 0, sizeof(req));
            //strcpy(req.BrokerID, BROKER_ID);
            //strcpy(req.InvestorID, INVESTOR_ID);
            req.BrokerID = _BrokerID;
            req.InvestorID = _InvestorID;

            int iResult = _traderApi.ReqQryTradingAccount(req);
            //cerr << "--->>> 请求查询资金账户: " << ((iResult == 0) ? "成功" : "失败") << endl;
        }

        /// <summary>
        /// 请求查询投资者持仓
        /// <summary>
        public void ReqQryInvestorPosition()
        {
            CSCThostFtdcQryInvestorPositionField req = new CSCThostFtdcQryInvestorPositionField();
            //memset(&req, 0, sizeof(req));
            //strcpy(req.BrokerID, BROKER_ID);
            //strcpy(req.InvestorID, INVESTOR_ID);
            //strcpy(req.InstrumentID, INSTRUMENT_ID);
            req.BrokerID = _BrokerID;
            req.InvestorID = _InvestorID;
            req.InstrumentID = "IF1205";
            int iResult = _traderApi.ReqQryInvestorPosition(req);
            //cerr << "--->>> 请求查询投资者持仓: " << ((iResult == 0) ? "成功" : "失败") << endl;

        }

        /// <summary>
        /// 报单录入请求
        /// <summary>
        public void ReqOrderInsert()
        {
            CSCThostFtdcInputOrderField req = new CSCThostFtdcInputOrderField();
            //memset(&req, 0, sizeof(req));
            ///经纪公司代码
            //strcpy(req.BrokerID, BROKER_ID);
            req.BrokerID = _BrokerID;
            ///投资者代码
            //strcpy(req.InvestorID, INVESTOR_ID);
            req.InvestorID = _InvestorID;
            ///合约代码
            //strcpy(req.InstrumentID, INSTRUMENT_ID);
            req.InstrumentID = "IF1206";
            ///报单引用
            //strcpy(req.OrderRef, ORDER_REF);
            req.OrderRef = ORDER_REF;
            ///用户代码
            //	TThostFtdcUserIDType	UserID;
            ///报单价格条件: 限价
            req.OrderPriceType = (sbyte)CSTThostFtdcOrderPriceTypeType.CSTHOST_FTDC_OPT_LimitPrice;
            ///买卖方向: 
            req.Direction = (sbyte)CSTThostFtdcDirectionType.CSTHOST_FTDC_D_Buy;
            ///组合开平标志: 开仓

            //req.CombOffsetFlag = ((sbyte)CSTThostFtdcOffsetFlagType.CSTHOST_FTDC_OF_Open).ToString();
            req.CombOffsetFlag = ASCIIEncoding.ASCII.GetString(new byte[] { (byte)CSTThostFtdcOffsetFlagType.CSTHOST_FTDC_OF_Open });
            ///组合投机套保标志 
            req.CombHedgeFlag = ASCIIEncoding.ASCII.GetString(new byte[] { (byte)CSTThostFtdcHedgeFlagType.CSTHOST_FTDC_HF_Speculation });
            ///价格
            req.LimitPrice = 2500;
            ///数量: 1
            req.VolumeTotalOriginal = 1;
            ///有效期类型: 当日有效
            req.TimeCondition = (sbyte)CSTThostFtdcTimeConditionType.CSTHOST_FTDC_TC_GFD;
            ///GTD日期
            //	TThostFtdcDateType	GTDDate;
            ///成交量类型: 任何数量
            req.VolumeCondition = (sbyte)CSTThostFtdcVolumeConditionType.CSTHOST_FTDC_VC_AV;
            ///最小成交量: 1
            req.MinVolume = 1;
            ///触发条件: 立即
            req.ContingentCondition = (sbyte)CSTThostFtdcContingentConditionType.CSTHOST_FTDC_CC_Immediately;
            ///止损价
            //	TThostFtdcPriceType	StopPrice;
            ///强平原因: 非强平
            req.ForceCloseReason = (sbyte)CSTThostFtdcForceCloseReasonType.CSTHOST_FTDC_FCC_NotForceClose;
            ///自动挂起标志: 否
            req.IsAutoSuspend = 0;
            ///业务单元
            //	TThostFtdcBusinessUnitType	BusinessUnit;
            ///请求编号
            //	TThostFtdcRequestIDType	RequestID;
            ///用户强评标志: 否
            req.UserForceClose = 0;

            int iResult = _traderApi.ReqOrderInsert(req);
            //cerr << "--->>> 报单录入请求: " << ((iResult == 0) ? "成功" : "失败") << endl;

        }

        /// <summary>
        /// 报单操作请求
        /// <summary>

        static bool ORDER_ACTION_SENT = false;
        public void ReqOrderAction(CSCThostFtdcOrderField pOrder)
        {
	        //ORDER_ACTION_SENT = false;		  //是否发送了报单
	        if (ORDER_ACTION_SENT)
		        return;

	        CSCThostFtdcInputOrderActionField req = new CSCThostFtdcInputOrderActionField();
	        
	        ///经纪公司代码
	        //strcpy(req.BrokerID, pOrder->BrokerID);
            req.BrokerID = _BrokerID;
	        ///投资者代码
	        //strcpy(req.InvestorID, pOrder->InvestorID);
            req.InvestorID = _InvestorID;
	        ///报单操作引用
            //	TThostFtdcOrderActionRefType	OrderActionRef;
	        ///报单引用
            req.OrderRef = pOrder.OrderRef;
	        //strcpy(req.OrderRef, pOrder->OrderRef);
	        ///请求编号
            //	TThostFtdcRequestIDType	RequestID;
	        ///前置编号
	        req.FrontID = FRONT_ID;
	        ///会话编号
	        req.SessionID = SESSION_ID;
	        ///交易所代码
        //	TThostFtdcExchangeIDType	ExchangeID;
	        ///报单编号
        //	TThostFtdcOrderSysIDType	OrderSysID;
	        ///操作标志
	        req.ActionFlag = (sbyte)CSTThostFtdcActionFlagType.CSTHOST_FTDC_AF_Delete;
	        ///价格
        //	TThostFtdcPriceType	LimitPrice;
	        ///数量变化
        //	TThostFtdcVolumeType	VolumeChange;
	        ///用户代码
        //	TThostFtdcUserIDType	UserID;
	        ///合约代码
            req.InstrumentID = pOrder.InstrumentID;
	        //strcpy(req.InstrumentID, pOrder->InstrumentID);

	        int iResult = _traderApi.ReqOrderAction(req);
	        //cerr << "--->>> 报单操作请求: " << ((iResult == 0) ? "成功" : "失败") << endl;
	        ORDER_ACTION_SENT = true;   

        }


        /// <summary>
        /// 登出请求
        /// <summary>
        public void ReqUserLogout()
        {
            _traderApi.RegisterSpi(null);

            CSCThostFtdcUserLogoutField req = new CSCThostFtdcUserLogoutField(); ;
            req.BrokerID = _BrokerID;
            req.UserID = _InvestorID;

            int iResult = _traderApi.ReqUserLogout(req);
            //Thread.Sleep(1000);
            //Release();

        }

        public void Release()
        {
            _traderApi.Release();

        }

        ///当客户端与交易后台建立起通信连接时（还未登录前），该方法被调用。
        public void OnFrontConnected()
        {
            TraderTest.TraderTest1.DisplayError("当客户端与交易后台建立起通信连接时-OnFrontConnected");
            Thread.Sleep(1000);
            ReqUserLogin();


        }

        ///当客户端与交易后台通信连接断开时，该方法被调用。当发生这个情况后，API会自动重新连接，客户端可不做处理。
        ///@param nReason 错误原因
        ///        0x1001 网络读失败
        ///        0x1002 网络写失败
        ///        0x2001 接收心跳超时
        ///        0x2002 发送心跳失败
        ///        0x2003 收到错误报文
        public void OnFrontDisconnected(int nReason) { }

        ///心跳超时警告。当长时间未收到报文时，该方法被调用。
        ///@param nTimeLapse 距离上次接收报文的时间
        public void OnHeartBeatWarning(int nTimeLapse) { }

        ///客户端认证响应
        public void OnRspAuthenticate(CSCThostFtdcRspAuthenticateField pRspAuthenticateField, CSCThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast) { }


        ///登录请求响应
        public void OnRspUserLogin(CSCThostFtdcRspUserLoginField pRspUserLogin, CSCThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
        {
            TraderTest.TraderTest1.DisplayError("登录请求响应-OnRspUserLogin");
            Thread.Sleep(1000);

            if (bIsLast && !IsErrorRspInfo(pRspInfo))
            {
                // 保存会话参数
                FRONT_ID = pRspUserLogin.FrontID;
                SESSION_ID = pRspUserLogin.SessionID;
                int iNextOrderRef = Int32.Parse(pRspUserLogin.MaxOrderRef);
                iNextOrderRef++;
                ORDER_REF = iNextOrderRef.ToString();
                //sprintf(ORDER_REF, "%d", iNextOrderRef);
                ///获取当前交易日
                //cerr << "--->>> 获取当前交易日 = " << pUserApi->GetTradingDay() << endl;
                ///投资者结算结果确认
                ReqSettlementInfoConfirm();
            }

        }


        ///登出请求响应
        public void OnRspUserLogout(CSCThostFtdcUserLogoutField pUserLogout, CSCThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
        {

            TraderTest.TraderTest1.DisplayError("登出请求响应-OnRspUserLogout");


        }

        ///用户口令更新请求响应
        public void OnRspUserPasswordUpdate(CSCThostFtdcUserPasswordUpdateField pUserPasswordUpdate, CSCThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast) { }

        ///资金账户口令更新请求响应
        public void OnRspTradingAccountPasswordUpdate(CSCThostFtdcTradingAccountPasswordUpdateField pTradingAccountPasswordUpdate, CSCThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast) { }

        ///报单录入请求响应
        public void OnRspOrderInsert(CSCThostFtdcInputOrderField pInputOrder, CSCThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
        {
            TraderTest.TraderTest1.DisplayError("报单录入请求响应-OnRspOrderInsert");
            //cerr << "--->>> " << "OnRspOrderInsert" << endl;
            IsErrorRspInfo(pRspInfo);
        }

        ///预埋单录入请求响应
        public void OnRspParkedOrderInsert(CSCThostFtdcParkedOrderField pParkedOrder, CSCThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast) { }

        ///预埋撤单录入请求响应
        public void OnRspParkedOrderAction(CSCThostFtdcParkedOrderActionField pParkedOrderAction, CSCThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast) { }

        ///报单操作请求响应
        public void OnRspOrderAction(CSCThostFtdcInputOrderActionField pInputOrderAction, CSCThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast) { }

        ///查询最大报单数量响应
        public void OnRspQueryMaxOrderVolume(CSCThostFtdcQueryMaxOrderVolumeField pQueryMaxOrderVolume, CSCThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast) { }

        ///投资者结算结果确认响应
        public void OnRspSettlementInfoConfirm(CSCThostFtdcSettlementInfoConfirmField pSettlementInfoConfirm, CSCThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
        {
            TraderTest.TraderTest1.DisplayError("投资者结算结果确认响应-OnRspSettlementInfoConfirm");
            Thread.Sleep(1000);
            
            //cerr << "--->>> " << "OnRspSettlementInfoConfirm" << endl;
            if (bIsLast && !IsErrorRspInfo(pRspInfo))
            {
                ///请求查询合约
                ReqQryInstrument();
            }



        }


        ///删除预埋单响应
        public void OnRspRemoveParkedOrder(CSCThostFtdcRemoveParkedOrderField pRemoveParkedOrder, CSCThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast) { }

        ///删除预埋撤单响应
        public void OnRspRemoveParkedOrderAction(CSCThostFtdcRemoveParkedOrderActionField pRemoveParkedOrderAction, CSCThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast) { }

        ///请求查询报单响应
        public void OnRspQryOrder(CSCThostFtdcOrderField pOrder, CSCThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast) { }

        ///请求查询成交响应
        public void OnRspQryTrade(CSCThostFtdcTradeField pTrade, CSCThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast) { }

        ///请求查询投资者持仓响应
        public void OnRspQryInvestorPosition(CSCThostFtdcInvestorPositionField pInvestorPosition, CSCThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
        {
            TraderTest.TraderTest1.DisplayError("请求查询投资者持仓响应-OnRspQryInvestorPosition");
            Thread.Sleep(1000);
            if (bIsLast && !IsErrorRspInfo(pRspInfo))
            {
                ///报单录入请求
                ReqOrderInsert();
            }


        }

        ///请求查询资金账户响应
        public void OnRspQryTradingAccount(CSCThostFtdcTradingAccountField pTradingAccount, CSCThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
        {
            TraderTest.TraderTest1.DisplayError("请求查询资金账户响应-OnRspQryTradingAccount");
            Thread.Sleep(1000);
            if (bIsLast && !IsErrorRspInfo(pRspInfo))
            {
                ///请求查询投资者持仓
                ReqQryInvestorPosition();
            }

        }

        ///请求查询投资者响应
        public void OnRspQryInvestor(CSCThostFtdcInvestorField pInvestor, CSCThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast) { }

        ///请求查询交易编码响应
        public void OnRspQryTradingCode(CSCThostFtdcTradingCodeField pTradingCode, CSCThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast) { }

        ///请求查询合约保证金率响应
        public void OnRspQryInstrumentMarginRate(CSCThostFtdcInstrumentMarginRateField pInstrumentMarginRate, CSCThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast) { }

        ///请求查询合约手续费率响应
        public void OnRspQryInstrumentCommissionRate(CSCThostFtdcInstrumentCommissionRateField pInstrumentCommissionRate, CSCThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast) { }

        ///请求查询交易所响应
        public void OnRspQryExchange(CSCThostFtdcExchangeField pExchange, CSCThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast) { }

        ///请求查询合约响应
        public void OnRspQryInstrument(CSCThostFtdcInstrumentField pInstrument, CSCThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
        {
            TraderTest.TraderTest1.DisplayError("请求查询合约响应-OnRspQryInstrument");
            Thread.Sleep(1000);

            if (bIsLast && !IsErrorRspInfo(pRspInfo))
            {
                ///请求查询资金
                ReqQryTradingAccount();
            }

        }

        ///请求查询行情响应
        public void OnRspQryDepthMarketData(CSCThostFtdcDepthMarketDataField pDepthMarketData, CSCThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast) { }

        ///请求查询投资者结算结果响应
        public void OnRspQrySettlementInfo(CSCThostFtdcSettlementInfoField pSettlementInfo, CSCThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast) { }

        ///请求查询转帐银行响应
        public void OnRspQryTransferBank(CSCThostFtdcTransferBankField pTransferBank, CSCThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast) { }

        ///请求查询投资者持仓明细响应
        public void OnRspQryInvestorPositionDetail(CSCThostFtdcInvestorPositionDetailField pInvestorPositionDetail, CSCThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast) { }

        ///请求查询客户通知响应
        public void OnRspQryNotice(CSCThostFtdcNoticeField pNotice, CSCThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast) { }

        ///请求查询结算信息确认响应
        public void OnRspQrySettlementInfoConfirm(CSCThostFtdcSettlementInfoConfirmField pSettlementInfoConfirm, CSCThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast) { }

        ///请求查询投资者持仓明细响应
        public void OnRspQryInvestorPositionCombineDetail(CSCThostFtdcInvestorPositionCombineDetailField pInvestorPositionCombineDetail, CSCThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast) { }

        ///查询保证金监管系统经纪公司资金账户密钥响应
        public void OnRspQryCFMMCTradingAccountKey(CSCThostFtdcCFMMCTradingAccountKeyField pCFMMCTradingAccountKey, CSCThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast) { }

        ///请求查询仓单折抵信息响应
        public void OnRspQryEWarrantOffset(CSCThostFtdcEWarrantOffsetField pEWarrantOffset, CSCThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast) { }

        ///请求查询转帐流水响应
        public void OnRspQryTransferSerial(CSCThostFtdcTransferSerialField pTransferSerial, CSCThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast) { }

        ///请求查询银期签约关系响应
        public void OnRspQryAccountregister(CSCThostFtdcAccountregisterField pAccountregister, CSCThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast) { }

        ///错误应答
        public void OnRspError(CSCThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast) { }

        ///报单通知
        public void OnRtnOrder(CSCThostFtdcOrderField pOrder)
        {
            //cerr << "--->>> " << "OnRtnOrder" << endl;
            TraderTest.TraderTest1.DisplayError("报单通知-OnRtnOrder");
            Thread.Sleep(1000);
            if (IsMyOrder(pOrder))
            {
                if (IsTradingOrder(pOrder))
                    ReqOrderAction(pOrder);
                else if (pOrder.OrderStatus == (sbyte)CSTThostFtdcOrderStatusType.CSTHOST_FTDC_OST_Canceled)
                //cout << "--->>> 撤单成功" << endl;
                {

                    TraderTest.TraderTest1.DisplayError("撤单成功") ;

                    ///登出请求
                    ReqUserLogout();

                }
            }



        }

        ///成交通知
        public void OnRtnTrade(CSCThostFtdcTradeField pTrade) { }

        ///报单录入错误回报
        public void OnErrRtnOrderInsert(CSCThostFtdcInputOrderField pInputOrder, CSCThostFtdcRspInfoField pRspInfo) { }

        ///报单操作错误回报
        public void OnErrRtnOrderAction(CSCThostFtdcOrderActionField pOrderAction, CSCThostFtdcRspInfoField pRspInfo) { }

        ///合约交易状态通知
        public void OnRtnInstrumentStatus(CSCThostFtdcInstrumentStatusField pInstrumentStatus) { }

        ///交易通知
        public void OnRtnTradingNotice(CSCThostFtdcTradingNoticeInfoField pTradingNoticeInfo) { }

        ///提示条件单校验错误
        public void OnRtnErrorConditionalOrder(CSCThostFtdcErrorConditionalOrderField pErrorConditionalOrder) { }

        ///请求查询签约银行响应
        public void OnRspQryContractBank(CSCThostFtdcContractBankField pContractBank, CSCThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast) { }

        ///请求查询预埋单响应
        public void OnRspQryParkedOrder(CSCThostFtdcParkedOrderField pParkedOrder, CSCThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast) { }

        ///请求查询预埋撤单响应
        public void OnRspQryParkedOrderAction(CSCThostFtdcParkedOrderActionField pParkedOrderAction, CSCThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast) { }

        ///请求查询交易通知响应
        public void OnRspQryTradingNotice(CSCThostFtdcTradingNoticeField pTradingNotice, CSCThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast) { }

        ///请求查询经纪公司交易参数响应
        public void OnRspQryBrokerTradingParams(CSCThostFtdcBrokerTradingParamsField pBrokerTradingParams, CSCThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast) { }

        ///请求查询经纪公司交易算法响应
        public void OnRspQryBrokerTradingAlgos(CSCThostFtdcBrokerTradingAlgosField pBrokerTradingAlgos, CSCThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast) { }

        ///银行发起银行资金转期货通知
        public void OnRtnFromBankToFutureByBank(CSCThostFtdcRspTransferField pRspTransfer) { }

        ///银行发起期货资金转银行通知
        public void OnRtnFromFutureToBankByBank(CSCThostFtdcRspTransferField pRspTransfer) { }

        ///银行发起冲正银行转期货通知
        public void OnRtnRepealFromBankToFutureByBank(CSCThostFtdcRspRepealField pRspRepeal) { }

        ///银行发起冲正期货转银行通知
        public void OnRtnRepealFromFutureToBankByBank(CSCThostFtdcRspRepealField pRspRepeal) { }

        ///期货发起银行资金转期货通知
        public void OnRtnFromBankToFutureByFuture(CSCThostFtdcRspTransferField pRspTransfer) { }

        ///期货发起期货资金转银行通知
        public void OnRtnFromFutureToBankByFuture(CSCThostFtdcRspTransferField pRspTransfer) { }

        ///系统运行时期货端手工发起冲正银行转期货请求，银行处理完毕后报盘发回的通知
        public void OnRtnRepealFromBankToFutureByFutureManual(CSCThostFtdcRspRepealField pRspRepeal) { }

        ///系统运行时期货端手工发起冲正期货转银行请求，银行处理完毕后报盘发回的通知
        public void OnRtnRepealFromFutureToBankByFutureManual(CSCThostFtdcRspRepealField pRspRepeal) { }

        ///期货发起查询银行余额通知
        public void OnRtnQueryBankBalanceByFuture(CSCThostFtdcNotifyQueryAccountField pNotifyQueryAccount) { }

        ///期货发起银行资金转期货错误回报
        public void OnErrRtnBankToFutureByFuture(CSCThostFtdcReqTransferField pReqTransfer, CSCThostFtdcRspInfoField pRspInfo) { }

        ///期货发起期货资金转银行错误回报
        public void OnErrRtnFutureToBankByFuture(CSCThostFtdcReqTransferField pReqTransfer, CSCThostFtdcRspInfoField pRspInfo) { }

        ///系统运行时期货端手工发起冲正银行转期货错误回报
        public void OnErrRtnRepealBankToFutureByFutureManual(CSCThostFtdcReqRepealField pReqRepeal, CSCThostFtdcRspInfoField pRspInfo) { }

        ///系统运行时期货端手工发起冲正期货转银行错误回报
        public void OnErrRtnRepealFutureToBankByFutureManual(CSCThostFtdcReqRepealField pReqRepeal, CSCThostFtdcRspInfoField pRspInfo) { }

        ///期货发起查询银行余额错误回报
        public void OnErrRtnQueryBankBalanceByFuture(CSCThostFtdcReqQueryAccountField pReqQueryAccount, CSCThostFtdcRspInfoField pRspInfo) { }

        ///期货发起冲正银行转期货请求，银行处理完毕后报盘发回的通知
        public void OnRtnRepealFromBankToFutureByFuture(CSCThostFtdcRspRepealField pRspRepeal) { }

        ///期货发起冲正期货转银行请求，银行处理完毕后报盘发回的通知
        public void OnRtnRepealFromFutureToBankByFuture(CSCThostFtdcRspRepealField pRspRepeal) { }

        ///期货发起银行资金转期货应答
        public void OnRspFromBankToFutureByFuture(CSCThostFtdcReqTransferField pReqTransfer, CSCThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast) { }

        ///期货发起期货资金转银行应答
        public void OnRspFromFutureToBankByFuture(CSCThostFtdcReqTransferField pReqTransfer, CSCThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast) { }

        ///期货发起查询银行余额应答
        public void OnRspQueryBankAccountMoneyByFuture(CSCThostFtdcReqQueryAccountField pReqQueryAccount, CSCThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast) { }

        ///银行发起银期开户通知
        public void OnRtnOpenAccountByBank(CSCThostFtdcOpenAccountField pOpenAccount) { }

        ///银行发起银期销户通知
        public void OnRtnCancelAccountByBank(CSCThostFtdcCancelAccountField pCancelAccount) { }

        ///银行发起变更银行账号通知
        public void OnRtnChangeAccountByBank(CSCThostFtdcChangeAccountField pChangeAccount) { }


    }
}
